Skip to content

Fix nonblocking dispatch watcher polling#10

Open
amittell wants to merge 3 commits into
mainfrom
fix-dispatch-stale-agent-session
Open

Fix nonblocking dispatch watcher polling#10
amittell wants to merge 3 commits into
mainfrom
fix-dispatch-stale-agent-session

Conversation

@amittell
Copy link
Copy Markdown
Owner

@amittell amittell commented Jun 2, 2026

Summary

  • make dispatch/chilisaus delivery watchers cron quick-poll jobs instead of long-running at-job shell watchers
  • preserve post-office delivery for terminal completion/error output while skipping pending watcher ticks cleanly
  • keep stale-session detection from treating watcher heartbeats as agent liveness
  • add regression coverage for watcher starvation, pending quick-poll ticks, terminal delivery, and stale-session behavior

Verification

  • node --test tests/delivery-fixes.test.mjs
  • cd ~/.openclaw/chilisaus && node --test tests/watcher.test.mjs tests/watcher-delivery.test.mjs tests/status-liveness.test.mjs
  • SCHEDULER_DB=:memory: node test.js
  • node --check on touched source and active runtime watcher files
  • git diff --check

No gateway or scheduler restart performed.

Copilot AI review requested due to automatic review settings June 2, 2026 01:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the dispatch delivery watcher to detect and fail “running” labels whose underlying agent sessions have stalled (even when the watcher heartbeat is still fresh), while avoiding false failures during long-running tool calls by inspecting the JSONL transcript tail.

Changes:

  • Add stall detection for running sessions using sessions.json + JSONL activity signals and fail the label with a clear error summary.
  • Add a JSONL-tail check to detect pending tool handoffs even when transcript mtime is flat.
  • Persist an error field when marking labels as error, and add a lightweight regression test.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dispatch/watcher.mjs Adds stall detection, pending-tool safeguards, and records entry.error when failing a label.
tests/delivery-fixes.test.mjs Adds a regression test ensuring the new watcher stall-detection hooks are present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dispatch/watcher.mjs
Comment thread tests/delivery-fixes.test.mjs Outdated
@amittell amittell force-pushed the fix-dispatch-stale-agent-session branch from 65666fe to 6b2eca8 Compare June 2, 2026 02:08
@amittell amittell force-pushed the fix-dispatch-stale-agent-session branch from 6b2eca8 to 2b242a8 Compare June 2, 2026 02:35
@amittell amittell changed the title Fix dispatch watcher stale agent sessions Fix nonblocking dispatch watcher polling Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants